#!/usr/bin/env python

import sys
import os
import string



if len(sys.argv) == 2:
    top_dir = sys.argv[1]
else:
    top_dir = ''

all_entries = []
for line in os.popen('du -k %s' % (top_dir) ).readlines():
    (size, directory) = line.split(None, 1)
    components = directory.rstrip().split('/')
    all_entries.append((int(size), components))

all_entries.reverse()
for size, path in all_entries:
    print ' ' * (8 * (len(path)-1)) + '%8d %s' % (size, string.join(path, '/'))
